package com.zxy.ziems.server.alarm.enums;

import com.zxy.ziems.server.vo.OptionsVO;

import java.util.*;

/**
 * @Copyright (C),
 * @ClassName: AlarModeEnum
 * @Author: yanzhiwei
 * @Description:
 * @Date: 2024/4/15 16:24
 */
public enum AlarmModeEnum {
    ALART("1", "系统内弹窗通知"),

    ;

    private final String code;
    private final String info;

    AlarmModeEnum(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }

    public static AlarmModeEnum getByCode(Integer code) {
        for (AlarmModeEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static List<OptionsVO> mapTolist() {
        return Arrays.asList(AlarmModeEnum.values()).stream()
                .map(m -> {
                    OptionsVO optionsVO = new OptionsVO();
                    optionsVO.setLabel(m.getInfo());
                    optionsVO.setValue(m.getCode());
                    return optionsVO;
                })
                .toList();
    }

    public static void main(String[] args) {
        List<Map<String, String>> list = new ArrayList<>();

        for (AlarmModeEnum value : AlarmModeEnum.values()) {
            Map<String, String> map = new HashMap<>();
            map.put(value.getCode(), value.getInfo());
            list.add(map);
        }


    }
}
